package applauncher;

import java.net.UnknownHostException;
import java.util.List;

import vrann.dataformats.json.JsonElement;

import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.Mongo;
import com.mongodb.MongoException;

public final class MongoAdapter {

	
	protected Mongo stmt;
	
	protected DB db;
	
	private static MongoAdapter instance = null;
	
	protected String host = "localhost";
	
	protected String dbName = "soapplauncher";
	
	protected String userName;
	
	protected char[] userPassword;
	
	private MongoAdapter() throws UnknownHostException, MongoException
	{
		stmt = new Mongo(host);
		if (userName.length() > 0) {
			boolean auth = db.authenticate(userName, userPassword);
		}
		db = stmt.getDB(dbName);
	}
	
	public static MongoAdapter getInstance()
	{
		if (instance == null) {
			try {
				instance = new MongoAdapter();
			} catch (Exception e) {

			}
		}
		return instance;
	}
	
	public DB getDb()
	{
		return db;
	}
	
	public BasicDBObject getDocumentFromJson(JsonElement documentData)
	{
		return new BasicDBObject();
	}
	
}
